package com.utils;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class HibCommons {
	private static SessionFactory sessionFactory;
	private static Session session;
	private static Transaction transaction;
	public static void OpenQuery(){
		Configuration conf = new Configuration().configure();
		sessionFactory = conf.buildSessionFactory();
		session = sessionFactory.openSession();
		transaction = session.beginTransaction();
	}
	
	public static void CloseQuery(){
		getTransaction().commit();
		getSession().close();
		getSessionFactory().close();
		
	}

	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public static void setSessionFactory(SessionFactory sessionFactory) {
		HibCommons.sessionFactory = sessionFactory;
	}

	public static Session getSession() {
		return session;
	}

	public static void setSession(Session session) {
		HibCommons.session = session;
	}

	public static Transaction getTransaction() {
		return transaction;
	}

	public static void setTransaction(Transaction transaction) {
		HibCommons.transaction = transaction;
	}

	
	

}
